﻿using Corina.Datamodel.Entities;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;

namespace Corina.DataContext.Service
{
    public class MeasureNotificationConfigurationService : ServiceBase
    {
        public List<MeasureNotificationConfigurationInfo> GetNitifyConfig(string connectionString,int messageId)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("SELECT tmnc.* FROM t_measure_notification_configuration AS tmnc ");
            builder.Append("LEFT JOIN t_user AS tu ON tu.Id = tmnc.UserId ");
            builder.Append("LEFT JOIN CORINA_PROD.dbo.t_device_sale AS tds ON tds.UserId = tu.Id ");
            builder.Append("LEFT JOIN CORINA_DATA.dbo.t_device_message AS tdm ON tdm.DeviceSn = tds.DeviceSn ");
            builder.Append("WHERE tdm.Id = @Id ");

            return DbOperator.GetEntities<MeasureNotificationConfigurationInfo>(connectionString, builder.ToString(), new SqlParameter("@Id", messageId));
        }
    }
}
